package com.jmoney.luckeylink.controller;

import static io.restassured.RestAssured.given;

import io.restassured.RestAssured;
import io.restassured.config.SSLConfig;
import io.restassured.response.Response;

public class LekeW_Announcement_Controller {
	static Object[] AnnouncementInfo=null;
	
    /**
	    * 指定接口地址，获取发布公告信息
	    * @param ApiUrl
	    * @return RoomUserMap
	    */
    public static Object[] GetAnnouncementInfo(String Method,String ApiUrl, String Param) throws Exception{

    	if("GET".equals(Method)){
    		Response response = given()
 	               .config((RestAssured.config().sslConfig(new SSLConfig().relaxedHTTPSValidation())))
 	               .contentType("application/json")
 	               .log().all()
 	               .request()
 	               .when()
 	               .get(ApiUrl);

 	       response.print();
            String Json = response.asString();
 	       
 	       int status_code = response.jsonPath().getInt("status_code");
 	       String message = response.jsonPath().get("message");

 	       String content = response.jsonPath().get("data.data[0].content");
 	       
           Object[] BulletinRecordInfo ={Json,status_code,message,content};
           
           AnnouncementInfo=BulletinRecordInfo;
    	}else if("POST".equals(Method)){
    	    Response response = given()
  	               .config((RestAssured.config().sslConfig(new SSLConfig().relaxedHTTPSValidation())))
  	               .contentType("application/x-www-form-urlencoded; charset=UTF-8")
  	               .log().all()
  	               .request()
  	               .body(Param)
  	               .when()
  	               .post(ApiUrl);

  	        response.print();
            String Json = response.asString();
  	       
  	        int status_code = response.jsonPath().getInt("status_code");
  	        String message = response.jsonPath().get("message");

            Object[] AnnouncementInfo1 ={Json,status_code,message};
            AnnouncementInfo=AnnouncementInfo1;
    	}
		return AnnouncementInfo; 
	}   
}
